Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

component-classes

Package Overview
Dependencies
Maintainers
32
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

component-classes

Cross-browser element class list

  • 1.2.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
451K
decreased by-8.81%
Maintainers
32
Weekly downloads
 
Created

What is component-classes?

The component-classes npm package is a utility for managing CSS classes on DOM elements. It provides a simple API to add, remove, and toggle classes, making it easier to manipulate class lists without directly interacting with the DOM's classList property.

What are component-classes's main functionalities?

Add Class

This feature allows you to add a new class to a DOM element. The code sample demonstrates how to create a new div element and add a class named 'new-class' to it.

const classes = require('component-classes');
const el = document.createElement('div');
classes(el).add('new-class');

Remove Class

This feature allows you to remove an existing class from a DOM element. The code sample shows how to remove the class 'existing-class' from a div element.

const classes = require('component-classes');
const el = document.createElement('div');
el.className = 'existing-class';
classes(el).remove('existing-class');

Toggle Class

This feature allows you to toggle a class on a DOM element. The code sample demonstrates how to toggle the class 'toggle-class' on a div element.

const classes = require('component-classes');
const el = document.createElement('div');
classes(el).toggle('toggle-class');

Check Class

This feature allows you to check if a DOM element has a specific class. The code sample shows how to check if the class 'check-class' is present on a div element.

const classes = require('component-classes');
const el = document.createElement('div');
el.className = 'check-class';
const hasClass = classes(el).has('check-class');

Other packages similar to component-classes

Keywords

FAQs

Package last updated on 01 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc